﻿Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient
Imports System.Text
Imports System.Web.Configuration
Imports System.IO


Partial Class Public_ExecSQL
    Inherits System.Web.UI.Page


    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim objReader As New StreamReader(Server.MapPath("~/Public/sql.txt"))
        Dim cmd As String = objReader.ReadToEnd()

        Dim connstring As String = WebConfigurationManager.ConnectionStrings("connStr").ConnectionString
        Try
            Dim myConn As New SqlConnection(connstring)
            Dim myCommand As SqlCommand

            myConn.Open()
            myCommand = New SqlCommand(cmd.ToString(), myConn)
            myCommand.ExecuteNonQuery()
            myConn.Close()
            MyObj.ShowMessage("Finish")
        Catch ex As Exception
            'MyObj.WriteLog(ex.ToString());
            MyObj.ShowMessage("Fail")
        End Try


    End Sub

End Class
